<template>
    <div class="paginationBox">
        <!-- 分页器 -->
        <div class="pagination">
            <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="currentPage" :page-sizes="[1,5,,8,10,20]" :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="tableData.length">
            </el-pagination>
        </div>
    </div>
</template>

<script>

export default {
    name: 'pagination',
    props: ['tableData'],
    data() {
        return {
            currentPage: 1, // 当前页码
            total: '', // 总条数
            pageSize: 8, // 每页的数据条数
        }
    },
    methods: {
        //每页条数改变时触发，选择一页显示多少行
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.currentPage = 1;
            this.pageSize = val;
            this.$emit('sizeChange',this.currentPage,this.pageSize)
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.$emit('currentChange',this.currentPage,this.pageSize)
        }
    }
}
</script>

<style scoped>

</style>